//
//  HashData.m
//  Pthread
//
//  Created by Yanyan Jiang on 2025/3/7.
//  Copyright © 2025 Yanyan Jiang. All rights reserved.
//

#import "NSData+Hash.h"
#import <CommonCrypto/CommonCrypto.h>

@implementation NSData (Hash)

- (NSData *)sha256Hash {
    unsigned char hash[CC_SHA256_DIGEST_LENGTH]; // 32字节
    CC_SHA256(self.bytes, (CC_LONG)self.length, hash);
    return [NSData dataWithBytes:hash length:CC_SHA256_DIGEST_LENGTH];
}

@end
